#include "vector.h"

//遍历方式
void test1(){
	vector<int> v;
	v.push_back(1);
	v.push_back(2);
	v.push_back(3);
	v.push_back(4);
	v.push_back(4);
	for (size_t i = 0; i < v.size(); i++)
	{
		cout << v[i] << " ";
	}
	cout << endl;

	vector<int>::iterator it = v.begin();
	while (it != v.end())
	{
		cout << *it << " ";
		it++;
	}
	cout << endl;

	for (auto i : v)
	{
		cout << i << " ";
	}
	cout << endl;


}
void test2(){
	vector<int> v;
	v.push_back(1);
	v.push_back(2);
	v.push_back(3);
	v.push_back(4);
	v.push_back(4);
	for (auto i : v)
	{
		cout << i << " ";
	}
	cout << endl;

	v.pop_back();
	v.pop_back();
	v.pop_back();
	v.pop_back();
	v.pop_back();
	for (auto i : v)
	{
		cout << i << " ";
	}
	cout << endl;

}

//插入
void test3(){
	vector<int> v;
	v.push_back(1);
	v.push_back(2);
	v.push_back(3);
	v.push_back(4);
	v.push_back(4);
	v.insert(v.begin(), 0);
	v.insert(v.begin() + 1, 40);
	v.insert(v.begin() + v.size(), 10);//尾插

	for (auto i : v)
	{
		cout << i << " ";
	}
	cout << endl;

}

//删除
void test4(){
	vector<int> v;
	v.push_back(1);
	v.push_back(2);
	v.push_back(3);
	v.push_back(4);
	v.push_back(4);
	v.erase(v.begin() + 1);
	for (auto i : v)
	{
		cout << i << " ";
	}
	cout << endl;

}


int main(){
	//test1();
	//test2();
	//test3();
	test4();
}